﻿/**********************************************************************************

	Project Name: SimpleAdmin CMS Theme
	Project Description: A clean admin theme
	File Name: script.js
	Author: Adi Purdila
	Author URI: http://www.adipurdila.com
	Version: 1.0.0
	
**********************************************************************************/
function ajaxdelterm(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTermInterest",
            data: { TableTermInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdeltermdemand(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTermDemandInterest",
            data: { TableTermDemandInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelhomeloaninterestrate(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableHomeLoanEquityInterest",
            data: { TableHomeLoanEquityInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelhomeloanmortgageinterestrate(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableHomeLoanMortgageInterest",
            data: { TableHomeLoanMortgageInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelcarloaninterestrate(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableCarLoanEquityInterest",
            data: { TableCarLoanEquityInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelcarloanmortgageinterestrate(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableCarLoanMortgageInterest",
            data: { TableCarLoanMortgageInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelTableCapitalLoanInterest(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableCapitalLoanInterest",
            data: { TableCapitalLoanInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelTableFinancialLeasingLoanInterest(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableFinancialLeasingLoanInterest",
            data: { TableFinancialLeasingLoanInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelTableLongTermLoanInterest(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableLongTermLoanInterest",
            data: { TableLongTermLoanInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelTableShortTermLoanInterest(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableShortTermLoanInterest",
            data: { TableShortTermLoanInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelconsumerloaninterestrate(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableConsumerLoanInterest",
            data: { TableConsumerLoanInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdeleducationloaninterestrate(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableEducationLoanInterest",
            data: { TableEducationLoanInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelOverdraftLoaninterestrate(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableOverdraftLoanInterest",
            data: { TableOverdraftLoanInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
function ajaxdelConsumerInstallmentLoaninterestrate(id) {
    var a = confirm("Bạn thật sự muốn xóa ?");
    if (a) {
        var AppUrl = $("#AppUrl").text();
        $.ajax({
            type: "post",
            url: AppUrl + "/Company/DeleteTableConsumerInstallmentLoanInterest",
            data: { TableConsumerInstallmentLoanInterestID: id },
            dataType: "json",
            success: function (rvdata) {
                window.location.reload();
            }
        });
    }
    return false;
}
$(document).ready(function () {
    var AppUrl = $("#AppUrl").text();
    //Content boxes expand/collapse
    $("#status").change(function () {
        var StatusID = $("#status").val();
        var url = "/CreditCard/getcreditcontractbystatus";
        var rowID = 0;
        var source = {
            datatype: "json",
            datafields: [
                               { name: 'CardApplyID', type: 'int' },
                               { name: 'StatusName', type: 'string' },
                               { name: 'CardImage', type: 'string' },
                               { name: 'CardName', type: 'string' },
                               { name: 'CustomerName', type: 'string' },
                               { name: 'CustomerEmail', type: 'string' },
                               { name: 'CustomerPhone', type: 'string' },
                               { name: 'AppDate', type: 'string' },
            ],
            id: 'CardApplyID',
            url: url,
            data: { StatusID: StatusID },
        };
        var imagerenderer = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="100" src="/content/upload/images/' + value + '"/>';
        }
        var imagerenderer_company = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="150" src="/content/upload/images/' + value + '"/>';
        }
        var flagimage = function (row, datafield, value) {
            return '<img style="margin-left: 38px;margin-top: 23px;width: auto;" height="25" width="40" src="/content/images/' + value + '"/>';
        }
        var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="margin: 5px; float: ' + columnproperties.cellsalign + ';">' + value + '</span>';

        }
        var InteresRate = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="display:block; text-align:center;">' + value + ' %</span>';

        }

        $("#grid_news").jqxGrid({
            width: '100%',
            source: source,
            rowsheight: 70,
            autoheight: true,
            pageable: true,
            sortable: true,
            altrows: true,
            enabletooltips: true,
            selectionmode: 'multiplecellsextended',
            columns: [
            { text: 'ID', datafield: 'CardApplyID', width: 53 },
            { text: 'Trạng thái', datafield: 'StatusName', width: 130, cellsrenderer: cellsrenderer },
            { text: 'Hình ảnh', datafield: 'CardImage', width: 120, height: 70, cellsrenderer: imagerenderer },
            { text: 'Khách hàng', datafield: 'CustomerName', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Email', datafield: 'CustomerEmail', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Số ĐT', datafield: 'CustomerPhone', width: 120, cellsrenderer: cellsrenderer },
            { text: 'Ngày tham gia', datafield: 'AppDate', width: 190, cellsrenderer: cellsrenderer },
            {
                text: 'Chi tiết', datafield: 'Chi tiết', columntype: 'button', width: 70, cellsrenderer: function () {
                    return "Chi tiết";
                }, buttonclick: function (editrow) {
                    var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                    window.location = "/CreditCard/ContractDetail/" + dataRecord.CardApplyID;
                }
            },

           {
               text: 'Xóa', datafield: 'Xóa', columntype: 'button', width: 70, cellsrenderer: function () {
                   return "Xóa";
               }, buttonclick: function (editrow) {

                   var comfim = confirm("Bạn có thật sự muốn xóa?");
                   if (comfim) {
                       var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                       $.ajax({
                           type: "POST",
                           url: "/CreditCard/DeleteCardApply",
                           datatype: "json",
                           data: { CardApplyID: dataRecord.CardApplyID },
                           success: function (result) {
                               if (result["Status"] == "OK") {
                                   alert("Xóa thành công");
                                   $("#grid_news").jqxGrid({ source: source });
                               }
                               else {

                                   alert("Xóa thất bại");
                               }
                           }
                       });
                   }


               }
           }
            ]
        });

    });
    $("#status-fuel").change(function () {
        var StatusID = $("#status-fuel").val();
        var url = "/SavingFuelCard/getfuelcontractbystatus";
        var rowID = 0;
        var source = {
            datatype: "json",
            datafields: [
                               { name: 'CardApplyID', type: 'int' },
                               { name: 'StatusName', type: 'string' },
                               { name: 'CardImage', type: 'string' },
                               { name: 'CardName', type: 'string' },
                               { name: 'CustomerName', type: 'string' },
                               { name: 'CustomerEmail', type: 'string' },
                               { name: 'CustomerPhone', type: 'string' },
                               { name: 'AppDate', type: 'string' },
            ],
            id: 'CardApplyID',
            url: url,
            data: { StatusID: StatusID },
        };
        var imagerenderer = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="100" src="/content/upload/images/' + value + '"/>';
        }
        var imagerenderer_company = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="150" src="/content/upload/images/' + value + '"/>';
        }
        var flagimage = function (row, datafield, value) {
            return '<img style="margin-left: 38px;margin-top: 23px;width: auto;" height="25" width="40" src="/content/images/' + value + '"/>';
        }
        var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="margin: 5px; float: ' + columnproperties.cellsalign + ';">' + value + '</span>';

        }
        var InteresRate = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="display:block; text-align:center;">' + value + ' %</span>';

        }

        $("#grid_news").jqxGrid({
            width: '100%',
            source: source,
            rowsheight: 70,
            autoheight: true,
            pageable: true,
            sortable: true,
            altrows: true,
            enabletooltips: true,
            selectionmode: 'multiplecellsextended',
            columns: [
            { text: 'ID', datafield: 'CardApplyID', width: 53 },
            { text: 'Trạng thái', datafield: 'StatusName', width: 130, cellsrenderer: cellsrenderer },
            { text: 'Hình ảnh', datafield: 'CardImage', width: 120, height: 70, cellsrenderer: imagerenderer },
            { text: 'Khách hàng', datafield: 'CustomerName', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Email', datafield: 'CustomerEmail', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Số ĐT', datafield: 'CustomerPhone', width: 120, cellsrenderer: cellsrenderer },
            { text: 'Ngày tham gia', datafield: 'AppDate', width: 190, cellsrenderer: cellsrenderer },
            {
                text: 'Chi tiết', datafield: 'Chi tiết', columntype: 'button', width: 70, cellsrenderer: function () {
                    return "Chi tiết";
                }, buttonclick: function (editrow) {
                    var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                    window.location = "/SavingFuelCard/ContractDetail/" + dataRecord.CardApplyID;
                }
            },

           {
               text: 'Xóa', datafield: 'Xóa', columntype: 'button', width: 70, cellsrenderer: function () {
                   return "Xóa";
               }, buttonclick: function (editrow) {

                   var comfim = confirm("Bạn có thật sự muốn xóa?");
                   if (comfim) {
                       var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                       $.ajax({
                           type: "POST",
                           url: "/SavingFuelCard/DeleteCardApply",
                           datatype: "json",
                           data: { CardApplyID: dataRecord.CardApplyID },
                           success: function (result) {
                               if (result["Status"] == "OK") {
                                   alert("Xóa thành công");
                                   $("#grid_news").jqxGrid({ source: source });
                               }
                               else {

                                   alert("Xóa thất bại");
                               }
                           }
                       });
                   }


               }
           }
            ]
        });

    });
    $("#status-restaurant").change(function () {
        var StatusID = $("#status-restaurant").val();
        var url = "/RestaurantCard/getfuelcontractbystatus";
        var rowID = 0;
        var source = {
            datatype: "json",
            datafields: [
                               { name: 'CardApplyID', type: 'int' },
                               { name: 'StatusName', type: 'string' },
                               { name: 'CardImage', type: 'string' },
                               { name: 'CardName', type: 'string' },
                               { name: 'CustomerName', type: 'string' },
                               { name: 'CustomerEmail', type: 'string' },
                               { name: 'CustomerPhone', type: 'string' },
                               { name: 'AppDate', type: 'string' },
            ],
            id: 'CardApplyID',
            url: url,
            data: { StatusID: StatusID },
        };
        var imagerenderer = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="100" src="/content/upload/images/' + value + '"/>';
        }
        var imagerenderer_company = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="150" src="/content/upload/images/' + value + '"/>';
        }
        var flagimage = function (row, datafield, value) {
            return '<img style="margin-left: 38px;margin-top: 23px;width: auto;" height="25" width="40" src="/content/images/' + value + '"/>';
        }
        var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="margin: 5px; float: ' + columnproperties.cellsalign + ';">' + value + '</span>';

        }
        var InteresRate = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="display:block; text-align:center;">' + value + ' %</span>';

        }

        $("#grid_news").jqxGrid({
            width: '100%',
            source: source,
            rowsheight: 70,
            autoheight: true,
            pageable: true,
            sortable: true,
            altrows: true,
            enabletooltips: true,
            selectionmode: 'multiplecellsextended',
            columns: [
            { text: 'ID', datafield: 'CardApplyID', width: 53 },
            { text: 'Trạng thái', datafield: 'StatusName', width: 130, cellsrenderer: cellsrenderer },
            { text: 'Hình ảnh', datafield: 'CardImage', width: 120, height: 70, cellsrenderer: imagerenderer },
            { text: 'Khách hàng', datafield: 'CustomerName', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Email', datafield: 'CustomerEmail', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Số ĐT', datafield: 'CustomerPhone', width: 120, cellsrenderer: cellsrenderer },
            { text: 'Ngày tham gia', datafield: 'AppDate', width: 190, cellsrenderer: cellsrenderer },
            {
                text: 'Chi tiết', datafield: 'Chi tiết', columntype: 'button', width: 70, cellsrenderer: function () {
                    return "Chi tiết";
                }, buttonclick: function (editrow) {
                    var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                    window.location = "/RestaurantCard/ContractDetail/" + dataRecord.CardApplyID;
                }
            },

           {
               text: 'Xóa', datafield: 'Xóa', columntype: 'button', width: 70, cellsrenderer: function () {
                   return "Xóa";
               }, buttonclick: function (editrow) {

                   var comfim = confirm("Bạn có thật sự muốn xóa?");
                   if (comfim) {
                       var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                       $.ajax({
                           type: "POST",
                           url: "/RestaurantCard/DeleteCardApply",
                           datatype: "json",
                           data: { CardApplyID: dataRecord.CardApplyID },
                           success: function (result) {
                               if (result["Status"] == "OK") {
                                   alert("Xóa thành công");
                                   $("#grid_news").jqxGrid({ source: source });
                               }
                               else {

                                   alert("Xóa thất bại");
                               }
                           }
                       });
                   }


               }
           }
            ]
        });

    });
    $("#status-travel").change(function () {
        var StatusID = $("#status-travel").val();
        var url = "/TravelCard/getfuelcontractbystatus";
        var rowID = 0;
        var source = {
            datatype: "json",
            datafields: [
                               { name: 'CardApplyID', type: 'int' },
                               { name: 'StatusName', type: 'string' },
                               { name: 'CardImage', type: 'string' },
                               { name: 'CardName', type: 'string' },
                               { name: 'CustomerName', type: 'string' },
                               { name: 'CustomerEmail', type: 'string' },
                               { name: 'CustomerPhone', type: 'string' },
                               { name: 'AppDate', type: 'string' },
            ],
            id: 'CardApplyID',
            url: url,
            data: { StatusID: StatusID },
        };
        var imagerenderer = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="100" src="/content/upload/images/' + value + '"/>';
        }
        var imagerenderer_company = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="150" src="/content/upload/images/' + value + '"/>';
        }
        var flagimage = function (row, datafield, value) {
            return '<img style="margin-left: 38px;margin-top: 23px;width: auto;" height="25" width="40" src="/content/images/' + value + '"/>';
        }
        var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="margin: 5px; float: ' + columnproperties.cellsalign + ';">' + value + '</span>';

        }
        var InteresRate = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="display:block; text-align:center;">' + value + ' %</span>';

        }

        $("#grid_news").jqxGrid({
            width: '100%',
            source: source,
            rowsheight: 70,
            autoheight: true,
            pageable: true,
            sortable: true,
            altrows: true,
            enabletooltips: true,
            selectionmode: 'multiplecellsextended',
            columns: [
            { text: 'ID', datafield: 'CardApplyID', width: 53 },
            { text: 'Trạng thái', datafield: 'StatusName', width: 130, cellsrenderer: cellsrenderer },
            { text: 'Hình ảnh', datafield: 'CardImage', width: 120, height: 70, cellsrenderer: imagerenderer },
            { text: 'Khách hàng', datafield: 'CustomerName', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Email', datafield: 'CustomerEmail', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Số ĐT', datafield: 'CustomerPhone', width: 120, cellsrenderer: cellsrenderer },
            { text: 'Ngày tham gia', datafield: 'AppDate', width: 190, cellsrenderer: cellsrenderer },
            {
                text: 'Chi tiết', datafield: 'Chi tiết', columntype: 'button', width: 70, cellsrenderer: function () {
                    return "Chi tiết";
                }, buttonclick: function (editrow) {
                    var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                    window.location = "/TravelCard/ContractDetail/" + dataRecord.CardApplyID;
                }
            },

           {
               text: 'Xóa', datafield: 'Xóa', columntype: 'button', width: 70, cellsrenderer: function () {
                   return "Xóa";
               }, buttonclick: function (editrow) {

                   var comfim = confirm("Bạn có thật sự muốn xóa?");
                   if (comfim) {
                       var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                       $.ajax({
                           type: "POST",
                           url: "/TravelCard/DeleteCardApply",
                           datatype: "json",
                           data: { CardApplyID: dataRecord.CardApplyID },
                           success: function (result) {
                               if (result["Status"] == "OK") {
                                   alert("Xóa thành công");
                                   $("#grid_news").jqxGrid({ source: source });
                               }
                               else {

                                   alert("Xóa thất bại");
                               }
                           }
                       });
                   }


               }
           }
            ]
        });

    });
    $("#status-shopping").change(function () {
        var StatusID = $("#status-shopping").val();
        var url = "/ShoppingCard/getfuelcontractbystatus";
        var rowID = 0;
        var source = {
            datatype: "json",
            datafields: [
                               { name: 'CardApplyID', type: 'int' },
                               { name: 'StatusName', type: 'string' },
                               { name: 'CardImage', type: 'string' },
                               { name: 'CardName', type: 'string' },
                               { name: 'CustomerName', type: 'string' },
                               { name: 'CustomerEmail', type: 'string' },
                               { name: 'CustomerPhone', type: 'string' },
                               { name: 'AppDate', type: 'string' },
            ],
            id: 'CardApplyID',
            url: url,
            data: { StatusID: StatusID },
        };
        var imagerenderer = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="100" src="/content/upload/images/' + value + '"/>';
        }
        var imagerenderer_company = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="150" src="/content/upload/images/' + value + '"/>';
        }
        var flagimage = function (row, datafield, value) {
            return '<img style="margin-left: 38px;margin-top: 23px;width: auto;" height="25" width="40" src="/content/images/' + value + '"/>';
        }
        var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="margin: 5px; float: ' + columnproperties.cellsalign + ';">' + value + '</span>';

        }
        var InteresRate = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="display:block; text-align:center;">' + value + ' %</span>';

        }

        $("#grid_news").jqxGrid({
            width: '100%',
            source: source,
            rowsheight: 70,
            autoheight: true,
            pageable: true,
            sortable: true,
            altrows: true,
            enabletooltips: true,
            selectionmode: 'multiplecellsextended',
            columns: [
            { text: 'ID', datafield: 'CardApplyID', width: 53 },
            { text: 'Trạng thái', datafield: 'StatusName', width: 130, cellsrenderer: cellsrenderer },
            { text: 'Hình ảnh', datafield: 'CardImage', width: 120, height: 70, cellsrenderer: imagerenderer },
            { text: 'Khách hàng', datafield: 'CustomerName', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Email', datafield: 'CustomerEmail', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Số ĐT', datafield: 'CustomerPhone', width: 120, cellsrenderer: cellsrenderer },
            { text: 'Ngày tham gia', datafield: 'AppDate', width: 190, cellsrenderer: cellsrenderer },
            {
                text: 'Chi tiết', datafield: 'Chi tiết', columntype: 'button', width: 70, cellsrenderer: function () {
                    return "Chi tiết";
                }, buttonclick: function (editrow) {
                    var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                    window.location = "/ShoppingCard/ContractDetail/" + dataRecord.CardApplyID;
                }
            },

           {
               text: 'Xóa', datafield: 'Xóa', columntype: 'button', width: 70, cellsrenderer: function () {
                   return "Xóa";
               }, buttonclick: function (editrow) {

                   var comfim = confirm("Bạn có thật sự muốn xóa?");
                   if (comfim) {
                       var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                       $.ajax({
                           type: "POST",
                           url: "/ShoppingCard/DeleteCardApply",
                           datatype: "json",
                           data: { CardApplyID: dataRecord.CardApplyID },
                           success: function (result) {
                               if (result["Status"] == "OK") {
                                   alert("Xóa thành công");
                                   $("#grid_news").jqxGrid({ source: source });
                               }
                               else {

                                   alert("Xóa thất bại");
                               }
                           }
                       });
                   }


               }
           }
            ]
        });

    });
    $("#status-atm").change(function () {
        var StatusID = $("#status-atm").val();
        var url = "/ATMCard/getfuelcontractbystatus";
        var rowID = 0;
        var source = {
            datatype: "json",
            datafields: [
                               { name: 'CardApplyID', type: 'int' },
                               { name: 'StatusName', type: 'string' },
                               { name: 'CardImage', type: 'string' },
                               { name: 'CardName', type: 'string' },
                               { name: 'CustomerName', type: 'string' },
                               { name: 'CustomerEmail', type: 'string' },
                               { name: 'CustomerPhone', type: 'string' },
                               { name: 'AppDate', type: 'string' },
            ],
            id: 'CardApplyID',
            url: url,
            data: { StatusID: StatusID },
        };
        var imagerenderer = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="100" src="/content/upload/images/' + value + '"/>';
        }
        var imagerenderer_company = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="150" src="/content/upload/images/' + value + '"/>';
        }
        var flagimage = function (row, datafield, value) {
            return '<img style="margin-left: 38px;margin-top: 23px;width: auto;" height="25" width="40" src="/content/images/' + value + '"/>';
        }
        var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="margin: 5px; float: ' + columnproperties.cellsalign + ';">' + value + '</span>';

        }
        var InteresRate = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="display:block; text-align:center;">' + value + ' %</span>';

        }

        $("#grid_news").jqxGrid({
            width: '100%',
            source: source,
            rowsheight: 70,
            autoheight: true,
            pageable: true,
            sortable: true,
            altrows: true,
            enabletooltips: true,
            selectionmode: 'multiplecellsextended',
            columns: [
            { text: 'ID', datafield: 'CardApplyID', width: 53 },
            { text: 'Trạng thái', datafield: 'StatusName', width: 130, cellsrenderer: cellsrenderer },
            { text: 'Hình ảnh', datafield: 'CardImage', width: 120, height: 70, cellsrenderer: imagerenderer },
            { text: 'Khách hàng', datafield: 'CustomerName', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Email', datafield: 'CustomerEmail', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Số ĐT', datafield: 'CustomerPhone', width: 120, cellsrenderer: cellsrenderer },
            { text: 'Ngày tham gia', datafield: 'AppDate', width: 190, cellsrenderer: cellsrenderer },
            {
                text: 'Chi tiết', datafield: 'Chi tiết', columntype: 'button', width: 70, cellsrenderer: function () {
                    return "Chi tiết";
                }, buttonclick: function (editrow) {
                    var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                    window.location = "/ATMCard/ContractDetail/" + dataRecord.CardApplyID;
                }
            },

           {
               text: 'Xóa', datafield: 'Xóa', columntype: 'button', width: 70, cellsrenderer: function () {
                   return "Xóa";
               }, buttonclick: function (editrow) {

                   var comfim = confirm("Bạn có thật sự muốn xóa?");
                   if (comfim) {
                       var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                       $.ajax({
                           type: "POST",
                           url: "/ATMCard/DeleteCardApply",
                           datatype: "json",
                           data: { CardApplyID: dataRecord.CardApplyID },
                           success: function (result) {
                               if (result["Status"] == "OK") {
                                   alert("Xóa thành công");
                                   $("#grid_news").jqxGrid({ source: source });
                               }
                               else {

                                   alert("Xóa thất bại");
                               }
                           }
                       });
                   }


               }
           }
            ]
        });

    });
    $(".btn-group").hover(function () {
        $(".dropdown-menu").show();
        
    }, function () {
        $(".dropdown-menu").hide();
    }
    
    );

});
